home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Utils / NEW - Update Notifier / Bin / update_notifier-0.1.1-fx+tb.xpi / components / nsUNItem.js next >
Encoding:
JavaScript  |  2006-02-21  |  2.0 KB  |  72 lines

  1. // Update Notifier
  2. // By Todd Long <longfocus@gmail.com>
  3. // http://www.longfocus.com/firefox/updatenotifier/
  4.  
  5. function UNItem() {}
  6. UNItem.prototype = {
  7.   _id: null,
  8.   _type: null,
  9.   _url: null,
  10.   _version: null,
  11.   
  12.   get id() { return this._id; },
  13.   get type() { return this._type; },
  14.   get url() { return this._url; },
  15.   get version() { return this._version; },
  16.   
  17.   set id(aId) { this._id = aId; },
  18.   set type(aType) { this._type = aType; },
  19.   set url(aURL) { this._url = aURL; },
  20.   set version(aVersion) { this._version = aVersion; },
  21.   
  22.   QueryInterface: function(iid)
  23.   {
  24.     if (!iid.equals(Components.interfaces.nsIUNItem) && 
  25.         !iid.equals(Components.interfaces.nsISupports))
  26.       throw Components.results.NS_ERROR_NO_INTERFACE;
  27.     return this;
  28.   }
  29. }
  30.  
  31. var myModule = {
  32.   firstTime: true,
  33.   
  34.   myCID: Components.ID("{c0e0d3e0-9e6b-11da-a746-0800200c9a66}"),
  35.   myDesc: "Item available for update",
  36.   myProgID: "@longfocus.com/updatenotifier/item;1",
  37.   myFactory: {
  38.     createInstance: function (outer, iid) {
  39.       if (outer != null)
  40.         throw Components.results.NS_ERROR_NO_AGGREGATION;
  41.       
  42.       return (new UNItem()).QueryInterface(iid);
  43.     }
  44.   },
  45.  
  46.   registerSelf: function (compMgr, fileSpec, location, type)
  47.   {
  48.     if (this.firstTime) {
  49.       this.firstTime = false;
  50.       throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
  51.     }
  52.     
  53.     compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  54.     compMgr.registerFactoryLocation(this.myCID, this.myDesc, this.myProgID, fileSpec, location, type);
  55.   },
  56.  
  57.   getClassObject: function (compMgr, cid, iid)
  58.   {
  59.     if (!cid.equals(this.myCID))
  60.       throw Components.results.NS_ERROR_NO_INTERFACE;
  61.     
  62.     if (!iid.equals(Components.interfaces.nsIFactory))
  63.       throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  64.     
  65.     return this.myFactory;
  66.   },
  67.   
  68.   canUnload: function(compMgr) { return true; }
  69. };
  70.  
  71. function NSGetModule(compMgr, fileSpec) { return myModule; }
  72.